#include <bits/stdc++.h>
using namespace std;
typedef unsigned int u32;
/*
CASE 1:
2
4
2 3 6 7
4
1 2 3 4
output:
2
-1

CASE 2:
2
5
32 32 32 32 32
4
32 67 55 22
output:
6
-1
*/
int main()
{
    freopen("file.in", "r", stdin);
    int t, n, i, j;
    u32 res, num, debug;
    cin >> t;
    for (i = 0; i < t; i++)
    {
        cin >> n;
        cin >> res;
        for (j = 0; j < n-1; j++)
        {
            cin >> num;
            res = res & num;
        }
        // init
        j = 0;
        bool flag = false;
        while (res)
        {
            if (res % 2 == 1)
            {
                cout << j + 1 << endl;
                flag = true;
                break;
            }
            res /= 2;
            j++;
        }
        if(!flag)
            cout << -1 << endl;
    }
    return 0;
}